package com.duobaoyu.dby.supply.biz.producer.deflistener;

import com.duobaoyu.dby.supply.core.rocketmq.constant.CommonTopicConstant;
import com.duobaoyu.dby.supply.core.rocketmq.listener.AbstractBroadcastListener;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.springframework.stereotype.Component;

/**
 * @Author tianxiaoqiang
 * @Date 2022/8/2 17:57
 * @Version 1.0
 * @Description 状态映射广播消息
 */
@Slf4j
@Component
@RequiredArgsConstructor
@RocketMQMessageListener(topic = CommonTopicConstant.LocalCacheBroadcast.TOPIC, consumerGroup = "${" + "spring.application.name" + ":" + "supply-chain-default" + "}" + "-broadcast-consumer", messageModel = MessageModel.BROADCASTING)
public class SupplyChainBroadcastConsumer extends AbstractBroadcastListener {

	@Override
	protected void beforeHandler(MessageExt message) {
		if(log.isDebugEnabled()) {
			log.debug("供应链{}广播消息Consumer接收到消息，messageid={}，message={},topic = {},tag = {}", this.applicationName, message.getMsgId(), message, message.getTopic(), message.getTags());
		}
	}

	@Override
	protected void afterHandler(MessageExt message, boolean result) {
		if(log.isDebugEnabled()) {
			log.debug("供应链{}广播消息Consumer接收到消息，message={},处理结果 result={}", this.applicationName, message, result);
		}
	}
}
